<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>登录</title>
	</head>
	<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.min.css"/>
	<body>
		<form class="form-inline">
		  <div class="form-group">
		    <label class="sr-only" for="username">账号</label>
		    <input type="text" class="form-control" id="username" placeholder="账号"/>
		  </div>
		  <div class="form-group">
		    <label class="sr-only" for="exampleInputPassword3">密码</label>
		    <input type="password" class="form-control" id="exampleInputPassword3" placeholder="密码"/>
		  </div>
		  <div class="checkbox">
		    <label>
		      <input type="checkbox"/> Remember me
		    </label>
		  </div>
	  	<button type="button" class="btn btn-default login">登录</button>
			<button type="button" class="btn btn-default regis">注册</button>

	</form>
	</body>
	<script src="/static/lib/jquery.js" type="text/javascript" charset="utf-8"></script>
	<script src="/static/lib/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
	<script type="text/javascript">

		//登录
		$(".login").on("click",function(){
            $.ajaxSetup({
                async :false
            });
			var username=$("#username").val();
			var password1=$("#exampleInputPassword3").val();
			$.post("/ajaxLogin",{
			"username" : username,
			"password" : password1
		}, function(result) {
			if (result.status == 200) {
				location.href = "/index";
			} else {
				alert(result.status);
			}
		});
		});
		//注册
		$(".regis").on("click",function () {
            $.ajaxSetup({
                async :false
            });
            var username=$("#username").val();
            var password1=$("#exampleInputPassword3").val();
            $.post("/ajaxRegis",{
                "username" : username,
                "password" : password1
            }, function(result) {
                if (result.success) {
                    alert(result.msg);
                } else {
                    alert(result.msg);
                }
        });
		});
	</script>
</html>
